package com.sc.pattern.pc;

/**
 * Created  on 2018/1/13.
 *
 * @author sc
 */
public class Consumer extends Thread {

    private final MessageQueue queue;

    public Consumer(MessageQueue queue){
        super("consumer");
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true){
        try {
            Message take = queue.take();
            System.out.println(take.getMessage());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    }
}
